home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / GMS / Source / Asm / Screens / LoadPicture.s < prev    next >
Encoding:
Text File  |  1997-05-01  |  3.4 KB  |  138 lines

  1. ;-------T-------T------------------------T----------------------------------;
  2. ;Load Picture
  3. ;------------
  4. ;This demo will load in a picture of any size/type and if it is larger than
  5. ;the screen width, it scrolls left and right.  This is easily possible due
  6. ;to the fact that GMS likes to fill in fields that have been set at zero
  7. ;on initialisation, which is great for loading/displaying things like
  8. ;pictures.
  9. ;
  10. ;The benefits of this will become more apparent when you want to do things
  11. ;like changing your graphics format from ECS to AGA and vice versa.  The
  12. ;benefits for the user are enormous (full graphical editing capabilities,
  13. ;if you program correctly).  And you don't even need to change a line of
  14. ;code!
  15.  
  16.     INCDIR    "INCLUDES:"
  17.     INCLUDE    "games/games_lib.i"
  18.     INCLUDE    "games/games.i"
  19.  
  20. CALL    MACRO
  21.     jsr    _LVO\1(a6)
  22.     ENDM
  23.  
  24. SPEED    =    2
  25.  
  26.     SECTION    "LoadPicture",CODE
  27.  
  28. ;===========================================================================;
  29. ;                             INITIALISE DEMO
  30. ;===========================================================================;
  31.  
  32.     STARTGMS
  33.  
  34. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  35.     move.l    GMSBase(pc),a6
  36.  
  37.     moveq    #VIDEOMEM|GETPALETTE,d0
  38.     lea    PictureFile(pc),a1
  39.     CALL    LoadPicFile
  40.     move.l    d0,Picture
  41.     beq.s    .Error_Picture
  42.  
  43.     CALL    GetScreen
  44.     move.l    d0,Screen
  45.     beq.s    .Error_Screen
  46.     move.l    d0,a0
  47.     move.l    Picture(pc),a1
  48.     move.w    PIC_Planes(a1),GS_Planes(a0)
  49.     move.w    PIC_Width(a1),GS_PicWidth(a0)
  50.     move.w    PIC_Height(a1),GS_PicHeight(a0)
  51.     move.l    PIC_AmtColours(a1),GS_AmtColours(a0)
  52.     move.w    PIC_ScrMode(a1),GS_ScrMode(a0)
  53.     move.w    PIC_ScrType(a1),GS_ScrType(a0)
  54.     move.l    #HSCROLL,GS_Attrib(a0)
  55.     move.w    #320,GS_ScrWidth(a0)
  56.     move.w    #256,GS_ScrHeight(a0)
  57.     move.l    PIC_Data(a1),GS_MemPtr1(a0)
  58.     CALL    LoadPic
  59.  
  60.     CALL    AddScreen
  61.     tst.l    d0
  62.     beq.s    .Error_Screen
  63.  
  64.     CALL    ShowScreen
  65.  
  66.     bsr.s    Main    ;Go and do the main routine.
  67.  
  68. .ReturnToDOS
  69.     move.l    GMSBase(pc),a6
  70.     move.l    Screen(pc),a0
  71.     CALL    DeleteScreen
  72. .Error_Screen
  73.     move.l    Picture(pc),a1
  74.     CALL    FreePic
  75. .Error_Picture
  76.     MOVEM.L    (SP)+,A0-A6/D1-D7
  77.     moveq    #ERR_OK,d0
  78.     rts
  79.  
  80. ;===========================================================================;
  81. ;                                MAIN LOOP
  82. ;===========================================================================;
  83.  
  84. Main:    move.l    GMSBase(pc),a6
  85.     move.l    Screen(pc),a0
  86.     move.l    Picture(pc),a2
  87.  
  88.     moveq    #0,d0    ;d0 = Initialise fader.
  89.     moveq    #2,d1    ;d1 = Speed of fade.
  90.     move.l    PIC_Palette(a2),a1
  91.     moveq    #$000000,d2
  92.     moveq    #0,d3
  93.     move.l    PIC_AmtColours(a2),d4
  94. .Fade1    CALL    WaitVBL
  95.     CALL    ColourToPalette    ;Do the fade routine.
  96.     tst.w    d0    ;Has the fade finished yet?
  97.     bne.s    .Fade1    ;If not, keep doing it.
  98.  
  99.     move.l    Picture(pc),a1
  100.     moveq    #0,d2
  101. .loop    CALL    WaitVBL
  102.     move.w    GS_ScrWidth(a0),d0    ;Only scroll the picture if is is
  103.     lsr.w    #3,d0    ;bigger than the actual screen.
  104.     cmp.w    GS_PicWidth(a0),d0
  105.     bge.s    .done
  106.  
  107.     tst.w    d2
  108.     bgt.s    .Right
  109. .Left    tst.w    GS_PicXOffset(a0)
  110.     ble.s    .RRight
  111. .RLeft    moveq    #-SPEED,d2
  112.     bra.s    .scroll
  113. .Right    move.w    GS_PicWidth(a0),d0    ;d0 = PicWidth.
  114.     sub.w    #320,d0
  115.     cmp.w    GS_PicXOffset(a0),d0    ;d0 = Is (Width-320 < PicOffset)?
  116.     ble.s    .RLeft
  117. .RRight    moveq    #SPEED,d2
  118. .scroll    add.w    d2,GS_PicXOffset(a0)
  119.     CALL    MovePicture
  120.  
  121. .done    moveq    #JPORT1,d0    ;Port 1 (Mouse)
  122.     moveq    #JT_ZBXY,d1
  123.     CALL    ReadJoyPort
  124.     btst    #MB_LMB,d0
  125.     beq.s    .loop
  126.     rts
  127.  
  128. ;===========================================================================;
  129. ;                                  DATA
  130. ;===========================================================================;
  131.  
  132. Screen:    dc.l    0
  133. Picture    dc.l    0
  134.  
  135. PictureFile:
  136.     dc.b    "GMS:demos/data/PIC.Pic640x256",0
  137.     even
  138.